<?php

namespace App\Console\Commands;

use App\Models\Reservation;
use Carbon\Carbon;
use Illuminate\Console\Command;

class CloseReservation extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'batch:closereservation';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '关闭超时约战';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $limitTime = Carbon::now()->addHour();
        Reservation::where([['status', 10], ['game_datetime', '<', $limitTime]])->update(['status' => 0]);
        Reservation::where([['status', 20], ['game_datetime', '<', $limitTime]])->update(['status' => 50]);
        $this->info('执行成功');

    }
}
